#include "Cr.h"

#if CR_ASSERTS_ENABLED

#include <stdio.h>
#include <string.h>
#include <stdarg.h>

namespace cr_debug
{
	void Assert(const char* szCondition, const char* szFile, long line, const char* szMessage, ...)
	{
		char buf[256];

		if (szMessage)
		{
			va_list args;
			va_start(args, szMessage);
			vsprintf_s(buf, szMessage, args);
		}
		else
		{
			sprintf_s(buf, sizeof(buf), "Assertion Failed\n");
		}

		CR_OUTPUT_STRING("");
		CR_OUTPUT_STRING("----------------------------------------------------");
		CR_OUTPUT_STRING("Assertion Failed");
		CR_OUTPUT_STRING("----------------------------------------------------");
		CR_OUTPUT_STRING1("File:      %s", szFile);
		CR_OUTPUT_STRING1("Line:      %d", line);
		CR_OUTPUT_STRING1("Condition: %s", szCondition);
		CR_OUTPUT_STRING1("Message:   %s", buf);
		CR_OUTPUT_STRING("----------------------------------------------------");
		CR_OUTPUT_STRING("");
	}
}

#endif // CR_ASSERTS_ENABLED
